<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<script src="<c:url value='/resources/js/manage.js'/>"></script>
<c:import url="../../../template/layout.jsp" charEncoding="UTF-8">
  <c:param name="title" value="码表类列表"/>
  <c:param name="body">


    <div class="content-title">码表类列表
      <p>${message.msg}</p>
    </div>
    <div class="container"
         style="background-color:#DCEAF4; width:1300px; height:500px;border-radius: 0px 0px 0px 0px;">
      <c:if test="${message!=null}">
        <div class="alert alert-danger" role="alert">${message.msg}</div>
      </c:if>
      <div class="btn-group pull-right" style="margin-bottom:8px;">
        <a class="btn btn-lg btn-primary" href="/system/code/edit">添加码表键值对
        </a>
      </div>
      <p></p>
      <div class="col-sm-5 col-sm-offset-1">
        <form id="searchForm" method="get" action="/system/code/list"
              name="user">
          <div class="input-group">
            <input id="pageNo" name="pageNo" type="hidden" value="${pager.pageNo}"/>
            <input id="pageSize" name="pageSize" type="hidden" value="${pager.pageSize}"/>


          </div>
        </form>
      </div>
      <div class="main-content">

        <table class="table">
          <thead>
          <tr>
            <th>所属码表</th>
            <th>码键</th>
            <th>码值</th>
            <th>描述</th>
            <th>操作</th>
          </tr>
          </thead>
          <tbody>
          <c:forEach items="${pager.list}" var="code">
            <%--<s:iterator value="#request.roleList" var="role">--%>
            <tr class="success">
              <td>${code.viewCodeType}</td>
              <td>${code.codeKey}</td>
              <td>${code.codeValue}</td>
              <td>${code.codeDescription}</td>
              <td>
                <button onclick="editCode('<c:url value="/system/code/getCode?id=${code.id}"/>')"
                        class="btn btn-primary btn-xs"
                        data-toggle="modal" data-target="#editCode">编辑
                </button>
                &nbsp;&nbsp;
                <button class="btn btn-primary btn-xs"
                        href="javascript:void(0)" data-toggle="tooltip" title="删除"
                        onclick="if (confirm('确认要删除本记录吗？此操作将不可恢复！'))
                                location = '<c:url
                                value="/system/code/delete?id=${code.id}"/>';
                                return false;">删除
                </button>


              </td>
            </tr>
            <%--</s:iterator>--%>
          </c:forEach>

          </tbody>
        </table>
      </div>
      <div class="row">
        <div class="col-sm-12">
            ${pager}
        </div>
      </div>
    </div>
    <script type="text/javascript">

      function editCode(path) {
        $.ajax({
          url: path,
          type: 'get',
          async: true,
          dataType: 'json',
          success: function (code) {
            alert(code.id);
            /*var temp = '<input class="edit_check" type="checkbox" name="permissions" />';
             $("#edit_per").removeChild(temp);*/
            $('#edit_id').val(code.id);
            $('#edit_viewCodeType').val(code.viewCodeType);
            $('#edit_codeKey').val(code.codeKey);
            $('#edit_codeValue').val(code.codeValue);
            $('#edit_codeDescription').val(code.codeDescription);
          }
        });
      }


    </script>
    <%--编辑修改模态框--%>
    <div class="modal fade" id="editCode" tabindex="-1" role="dialog">
      <div class="modal-dialog modal-lg">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal">
              <span aria-hidden="true">&times;</span>
              <span class="sr-only">Close</span>
            </button>
            <h3 class="modal-title">编辑</h3>
          </div>
          <div class="modal-body">
            <form name="code"  action="${pageContext.request.contextPath}/system/code/update" method="post">
              <div align="left" style="width: 300px; margin-right: auto; margin-left: auto;">
                <div class="form-group">
                  <label for="codetypeId" class="control-label" >码表类</label>

                    <input type="text" class="form-control" id="edit_viewCodeType" readonly>
                </div>
                <div class="form-group">
                  <label for="codeKey" class="control-label">码键</label>

                    <input type="number" class="form-control" id="edit_codeKey" name="codeKey" required>
                </div>

                <div class="form-group">
                  <label for="codeValue" class="control-label">码值</label>

                    <input type="text" class="form-control" id="edit_codeValue" name="codeValue" required>
                </div>
                <div class="form-group">
                  <label for="codeDescription" class="control-label">描述</label>

                    <input type="text" class="form-control" id="edit_codeDescription" name="codeDescription" required>
                </div>
                <input type="hidden" name="id" id="edit_id"/>
                <div class="form-group">
                  <div class="col-sm-offset-2 col-sm-10">
                    <input type="submit" value="提交" class="btn btn-primary"/> <input type="reset" value="重置"
                                                                                     class="btn btn-default"/>
                  </div>
                </div>
              </div>
            </form>
          </div>
        </div>
      </div>
    </div>

  </c:param>
</c:import>
